pp108 : Features of HTTP connector

Features of HTTP connector

HTTP connector provides connectivity to web servers over HTTP protocol and supports common HTTP operations like GET, POST, PUT, and DELETE. It can be used to invoke services over HTTP or HTTPS and can be used to invoke standard web services or REST based services with XML or JSON payloads.

It has the following features which help applications to communicate with the external web servers.

Support multiple servers

Using the same HTTP connector or container, you can connect to multiple hosts and invoke services. These services can be internal to the organization or available in the internet. HTTP connector configuration has connection details of various servers, identified by a name or ID that is unique. While processing the request, you must provide the connection ID that helps the connector to identify proper connection details.

A sample configuration in the XML store is as follows:

<configurations xmlns="http://httpconnector.opentext.com/1.0/configuration">
    <connections>
        <connection id="CONN-DELICIOUS-FEED">
            <url>http://feeds.delicious.com</url>
        </connection>
    </connections>
    <connections>
        <connection id="PRocess-PLATFORM-TASKS">
            <url>http://myserver:9123/cordys</url>
			<username>testuser</username>
			<password>YzByZHlz</password>
        </connection>
    </connections>
</configurations>

Organization aware behavior

By default, HTTP connector is organization-aware. The same HTTP connector in the shared space or system organization can be used to process requests from organizations or tenants with organization-specific configuration. The HTTP connector configuration is stored in the XML store, which by default is organization-aware. Based on the organization context of the user, the configuration is selected. If the configuration is available in a specific organization, HTTP connector uses the configuration available in that organization, else HTTP connector uses configuration available in the shared space.

Supports invoking standard web services and REST services

HTTP connector follows a pluggable request and response handling architecture. It supports web services with XML payload and REST-based services with JSON and XML payloads.

Service type Request handler Response handler Supported payloads
Web services com.opentext.applicationconnector.httpconnector.impl.StandardRequestHandler com.opentext.applicationconnector.httpconnector.impl.StandardResponseHandler XML
REST com.opentext.applicationconnector.httpconnector.impl.RestRequestHandler com.opentext.applicationconnector.httpconnector.impl.RestResponseHandler JSON, XML

For standard web services,

<implementation type= "HTTP" xmlns= "http://httpconnector.opentext.com/1.0/implementation"  xmlns:SOAP= "http://schemas.xmlsoap.org/soap/envelope/"  >
......
<request-handler  class = "com.opentext.applicationconnector.httpconnector.impl.StandardRequestHandler" />
<response-handler  class = "com.opentext.applicationconnector.httpconnector.impl.StandardResponseHandler" />
....
</implementation >

For REST services,

 

<implementation type= "HTTP" xmlns= "http://httpconnector.opentext.com/1.0/implementation"  xmlns:SOAP= "http://schemas.xmlsoap.org/soap/envelope/"  >
......
<request-handler  class = "com.opentext.applicationconnector.httpconnector.impl.RestRequestHandler" />
<response-handler  class = "com.opentext.applicationconnector.httpconnector.impl.RestResponseHandler" />
....
</implementation >

 

Multiple payload format

HTTP connectors can send input to services or receive output from services either in the XML or JSON format. Since Process Platform supports only SOAP based web services, all requests from Platform are in SOAP or XML format and HTTP connector transforms them to appropriate format.

If the input request is of the type HTTP POST and expects a JSON input, then set Content-type=application/json in the request header, as follows:

<implementation xmlns= "http://httpconnector.opentext.com/1.0/implementation"  xmlns:SOAP= "http://schemas.xmlsoap.org/soap/envelope/"  type= "HTTP" >
........................
<connection-id>JSON-TEST</connection-id> 
<request-handler  class = "com.opentext.applicationconnector.httpconnector.impl.RestRequestHandler" >
<req-headers>
<header name= "Content-Type" >application/json</header>
</req-headers> 
</request-handler>
<response-handler  class = "com.opentext.applicationconnector.httpconnector.impl.RestResponseHandler" />
<valid-response-code> 200 </valid-response-code>
................
</implementation>

Request and response transformation capability

You can use XSLT capability to transform a request to another request that is expected by the service or to transform the response from the service to the XML expected by the application. The XSLT can be stored in the XML store and can be used inside the HTTP connector. This can be done as follows:

 

<implementation xmlns= "http://httpconnector.opentext.com/1.0/implementation"  xmlns:SOAP= "http://schemas.xmlsoap.org/soap/envelope/"  type= "HTTP" >
........................
<connection-id>JSON-TEST</connection-id> 
<request-handler  class = "com.opentext.applicationconnector.httpconnector.impl.RestRequestHandler" >
<req-headers>
<header name= "Content-Type" >application/json</header>
</req-headers>
<xslt xmlstore= "xslts/request.xslt" /> 
</request-handler>
<response-handler  class = "com.opentext.applicationconnector.httpconnector.impl.RestResponseHandler" >
<xslt xmlstore= "xslts/response.xslt" />
</response-handler>
<valid-response-code> 200 </valid-response-code>
................
</implementation>

 

Authentication support

Though HTTP connector supports basic authentication, it also supports HTTPS.

Custom HTTP header support

You can add custom HTTP headers to the request while sending request.

 

<request-handler  class = "com.opentext.applicationconnector.httpconnector.impl.RestResponseHandler" >
...
<req-headers>
<header name= "x-ms-version" > 2012 - 03 - 01 </header>
<header name= "Content-Type" >application/xml</header>
</req-headers>
..
</request-handler>

URI parameters mapping

HTTP connector supports URI parameters in the request, which can be used to substitute the corresponding place holders in the URI, while sending the request to the web server.

Method implementation
 <implementation type="HTTP" xmlns="http://httpconnector.opentext.com/1.0/implementation" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
    <connection-id>CONN-DELICIOUS-FEED</connection-id>
    <http-method>GET</http-method>
    <uri>/v2/rss/{0}</uri>
    <request-handler class="com.opentext.applicationconnector.httpconnector.impl.RestRequestHandler">
        <uri-parameters>
            <parameter type="xpath">./Username</parameter>
        </uri-parameters>
    </request-handler>
    <response-handler class="com.opentext.applicationconnector.httpconnector.impl.StandardResponseHandler"/>
    <valid-response-code>200</valid-response-code>
    <namespaces/>
</implementation>
The URI parameter formats the URI according to the specified format. For example /v2/rss/{0}. The parameters {0}, {1}, and so on are filled with the parameters included in the URI parameters.

 

Note: The connection URI parameters start at 0.

 

The SOAP request from application to HTTP connector is as follows:

SOAP Request
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP:Body>
        <GetBookmarksForUser xmlns="http://com.opentext.httptest/rest">
            <Username>RestUser</Username>
        </GetBookmarksForUser>
    </SOAP:Body>
</SOAP:Envelope>
On execution of the above web service operation, the value of the Username tag is used as a URL parameter. The actual URL will be <server url in configuration> /v2/rss/ RestUser

Proxy support

HTTP connector can connect to the services using a proxy server in between with proper authentication support.

JMX counters

The HTTP connector specific performance counters that give a break up of the total time spent in processing requests are as follows:

  • RequestTransformation - Indicates the time spent in transforming incoming requests to HTTP requests.
  • HTTPRequestProcessing - Indicates the time spent in waiting for the HTTP response after sending the request.
  • ResponseTransformation - Indicates the time spent in transforming HTTP responses to the responses that are eventually sent to the client.
  • XMLToJsonTransformation - Indicates the time spent in converting XML in the SOAP request to JSON before sending it to the REST service.
  • JsonToXMLTransformation - Indicates the time spent in converting JSON in the response from the service to XML before sending the response to the Platform.

In addition to these counters, HTTP connector internally uses Process Platform connector to send requests to the XML store. It is a managed component and can be used to monitor the performance of the reads on the XML store.